package com.neusoft.ysu.populationmanagement.controller;


import com.neusoft.ysu.populationmanagement.entity.CommonResult;
import com.neusoft.ysu.populationmanagement.entity.OperationLog;
import com.neusoft.ysu.populationmanagement.service.IHouseholdService;
import com.neusoft.ysu.populationmanagement.service.IVResPopService;
import com.neusoft.ysu.populationmanagement.vo.VResPop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author 作者：赵子鉴
 * @since 2024-06-18
 */
@RestController
@RequestMapping("/v-res-pop")
@CrossOrigin
public class VResPopController {

    @Autowired
    private IVResPopService ivResPopService;

    /**
     * @param vResPop
     * @param operationLog
     * @return code=1代表成功，101代表失败
     * @author 张幸晔
     * @date 2024-06-19 14:28
     * @描述 户口立户
     */
    @RequestMapping("houseHoldRegistered")
    public CommonResult houseHoldRegistered(VResPop vResPop, OperationLog operationLog) {
        System.out.println(vResPop);
        System.out.println(operationLog);
        //人口表更新与户口表插入
        return ivResPopService.houseHoldRegistered(vResPop, operationLog);
    }

    /**
     * @param idNum
     * @return com.neusoft.ysu.populationmanagement.entity.CommonResult
     * @author 张幸晔
     * @date 2024-06-20 15:25
     * @描述 获取常住人口信息
     */
    @RequestMapping("selectResPopInfo")
    public CommonResult selectGuardianInfo(String idNum) {
        return ivResPopService.selectGuardianInfo(idNum);
    }

    /**
     * 户口申报api
     *
     * @param vResPop
     * @param operationLog
     * @return com.neusoft.ysu.populationmanagement.entity.CommonResult
     * @author 张幸晔
     * @date 2024-06-20 15:25
     */
    @RequestMapping("birthDeclaration")
    public CommonResult birthDeclaration(VResPop vResPop, OperationLog operationLog) {
        return ivResPopService.birthDeclaration(vResPop, operationLog);
    }

    /**
     * @param vResPop
     * @param operationLog
     * @return com.neusoft.ysu.populationmanagement.entity.CommonResult
     * 户口注销
     * @author 张幸晔
     * @date 2024-06-20 15:27
     */
    @RequestMapping("householdLogout")
    public CommonResult householdLogout(VResPop vResPop, OperationLog operationLog) {
        return ivResPopService.householdLogout(vResPop, operationLog);
    }


    /**
     * @param vResPops
     * @param operationLog
     * @return CommonResult:1代表成功，103代表失败
     * @description
     * @author 张幸晔
     * @date 2024-06-21 09:46
     * @描述 修改户主关系
     */

    @RequestMapping("changeHouseholdRelation")
    public CommonResult changeHouseholdRelation(@RequestBody List<VResPop> vResPops, OperationLog operationLog) {
        return ivResPopService.changeHouseholdRelation(vResPops, operationLog);
    }

    /**
     * @param vResPop
     * @param operationLog
     * @return com.neusoft.ysu.populationmanagement.entity.CommonResult
     * @author 张幸晔
     * @描述 户口迁移
     * @date 2024-06-22 08:52
     */
    @RequestMapping("householdMigrate")
    public CommonResult householdMigrate(VResPop vResPop, OperationLog operationLog) {
        return ivResPopService.householdMigrate(vResPop, operationLog);
    }

    @RequestMapping("/generatepop")
    public CommonResult generatepop(Integer num,Integer beginid) {
        return ivResPopService.generatepop(num,beginid);
    }

}
